package com.srxz.mobilepharmacy.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;
import java.math.BigInteger;

@Embeddable
@AllArgsConstructor
@NoArgsConstructor
@Data
public class UserInfoPK implements Serializable {
    @Column(name = "aid")
    private BigInteger aid;
    @Column(name = "typ")
    private Integer typ;
    @Column(name = "name")
    private String name;

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (aid == null ? 0 : aid.hashCode());
        result = prime * result + (typ == null ? 0 : typ.hashCode());
        result = prime * result + (name == null ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if(this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        UserInfoPK other = (UserInfoPK) obj;
        if (aid == null) {
           if (other.aid != null)
              return false;
        } else if (!aid.equals(other.aid))
           return false;

        if (typ == null) {
            if (other.typ != null)
                return false;
        } else if (!typ.equals(other.typ))
            return false;

        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;

        return true;
    }
}
